package com.atguigu.ggkt.interceptors;

import com.atguigu.ggkt.utils.LogTool;
import org.springframework.stereotype.Component;

import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;

@Component
public class WebServletRequestListener implements ServletRequestListener {
    public static AtomicInteger requestCount = new AtomicInteger(0);

    public void requestInitialized(ServletRequestEvent sre) {
        HttpServletRequest request = (HttpServletRequest)sre.getServletRequest();
        String servletPath = request.getServletPath();
        String host = request.getHeader("Host");
        LogTool.info(this.getClass(),servletPath+", uuid: from Host: "+host);
//        int result = requestCount.incrementAndGet();
        //LogTool.debug(this.getClass(),servletPath+", requestCount1++>: "+result);
    }

    public void requestDestroyed(ServletRequestEvent arg0) {
    }
}
